package xyz.hubery.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 远程调用授权服务
 */
@FeignClient(value = "authorization-server")
public interface OAuth2FeignClient {

    /**
     * 获取token
     * @param grantType 登录类型
     * @param username 用户名
     * @param password 密码
     * @param loginType 用户类型
     * @param basicToken 客户端信息加密
     * @return
     */
    @PostMapping("/oauth/token")
    ResponseEntity<JwtToken> getToken(@RequestParam("grant_type") String grantType,
                                      @RequestParam("username") String username,
                                      @RequestParam("password") String password,
                                      @RequestParam("login_type") String loginType,
                                       @RequestHeader("Authorization") String basicToken);
}
